package com.sbj.controller;

import com.zmh.framework.oss.OssConfigure;
import com.zmh.framework.util.Result;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author summer
 * @version 1.0
 * @date 2024/8/9 15:51
 */
@RestController
@RequestMapping(value = "/file")
@Slf4j
@AllArgsConstructor
public class FileController {

    private final OssConfigure ossConfigure;

    @PostMapping(value = "/uploadFile")
    public Result<String> uploadFile(MultipartFile file) {
        String path = ossConfigure.uploadFile(file);

        return Result.successResult(ossConfigure.getAccessUrl()+path);
    }
}
